package com.pf.java.File;

import java.io.*;

/**
 * 打印流
 *
 * ClassName:IO7
 * Package:com.pf.java.File
 *
 * @author: pf
 * @date: 2021/11/7-20:28
 */
public class IO7 {

    public static void main(String[] args) {
//        testPrintStream();
        testPrintWriter();
    }


    public static void testPrintStream() {
        try (
                FileOutputStream fos = new FileOutputStream("C:/Users/10970/Desktop/Java学习笔记/牛客网学习/a.txt");
                PrintStream ps = new PrintStream(fos);
                ){

            ps.println("龙宝是神！");
            ps.println("龙宝是神！");
            ps.println("龙宝是狗！");
            ps.println("龙宝是神！");
            ps.println("龙宝是神！");

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public static void testPrintWriter() {
        try(
                FileWriter fw = new FileWriter("C:/Users/10970/Desktop/Java学习笔记/牛客网学习/b.txt");
                PrintWriter pw = new PrintWriter(fw);
                ){

            pw.println("龙宝是sb");
            pw.println("龙宝是sb");
            pw.println("龙宝是sb");
            pw.println("龙宝是sb");
            pw.println("龙宝是sb");
            pw.println("龙宝是sb");
            pw.println("龙宝是sb");



        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
